import 'package:daoyi_ui_admin_getx/app/widgets/common_image_widget.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'function_button_item_data.dart';

class FunctionButtonItemWidget extends StatelessWidget {
  final FunctionButtonItemData data;

  const FunctionButtonItemWidget(this.data, {super.key});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        if (data.onTap != null) {
          data.onTap!();
        } else if (data.route != null) {
          Get.toNamed(data.route!);
        }
      },
      child: Container(
        width: 50,
        height: 60,
        margin: const EdgeInsets.all(5),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(10),
        ),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            CommonImageWidget(
              data.icon,
              width: 40,
              height: 40,
            ),
            Text(data.title),
          ],
        ),
      ),
    );
  }
}
